from rest_framework.mixins import RetrieveModelMixin
from rest_framework.viewsets import GenericViewSet

from apps.models import HouseKeeping
from apps.serializers.ListHousekeeping import ListThingSerializer
from apps.utils.common_mixin import APIListModelMixin, APIRetrieveModelMixin
from apps.utils.common_response import APIResponse


class ShoppingList(GenericViewSet,APIRetrieveModelMixin):
    # queryset = HouseKeeping.objects.all()
    # serializer_class = ListThingSerializer
    def list(self, request):
        id = request.GET.get('id',None)
        print(id)
        if id:
            queryset = HouseKeeping.objects.filter(id=id).first()
            serializer = ListThingSerializer(queryset, data=request.data)
            if serializer.is_valid():
                return APIResponse(msg='页面加载成功', data=serializer.data)
        else:
            return APIResponse(code=1, msg='页面失效')
